<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>filterNonUniqueBy</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const filterNonUniqueBy = (arr, handler) =>
            arr.filter((v, i) => arr.every((x, j) => (i === j) === handler(v, x, i, j)));
        console.log(
            filterNonUniqueBy(
                [
                    { id: 0, value: 'a' },
                    { id: 1, value: 'b' },
                    { id: 2, value: 'c' },
                    { id: 1, value: 'd' },
                    { id: 0, value: 'e' }
                ],
                (a, b) => a.id === b.id
            )
        );
    </script>
</body>

</html>